package com.way.api.mall.fallback;

import com.way.api.mall.RemoteOrderService;
import com.way.domain.mall.Order;
import com.way.dto.CommonResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RemoteOrderFallback implements FallbackFactory<RemoteOrderService> {

    @Override
    public RemoteOrderService create(Throwable throwable) {
        log.error("调用order接口失败",throwable.getMessage());
        return new RemoteOrderService() {
            @Override
            public CommonResult createOrder(Order order) {
                return CommonResult.fail();
            }
        };
    }
}
